<%@ page language="java" session="true" errorPage="ElderhealthError.jsp"%>
<%@ page import="com.elderhealth.worker.HomecareWorker"%>
<%
/*
 * Source:   ShowWorkerSearchResults.jsp
 * Purpose:  This page takes in a Worker object array to display as search results
 */
%>

<html>
<head>
<link rel="stylesheet" type="text/css" href="elderhealth.css">
<!-- Scripting Portion -->
<script type="text/javascript" src="elderhealth.js"></script>
</head>
<body>

<%@ include file="ElderhealthHeader.jsp" %>

<%
  /* Write code to retrieve results and present them */
  HomecareWorker[] WorkerResults = (HomecareWorker[])session.getAttribute("results"); 
  
%>

<table border=0 align="left" border=0 cellpadding=0 cellspacing=0 width="600">
    <tr class="contactHeaderText"><td height="18" align="left" valign="middle" style="PADDING-LEFT:10px">Show Search Results</td></tr>
    <tr><td class="layoutLine" valign="middle" align="left" width="302" height="1" colSpan="4"></td></tr>
    <tr class="contactBar1">
	  <td align="left" valign="middle" style="PADDING-LEFT:10px">
<%
if (WorkerResults == null || WorkerResults.length == 0)
{
%>
      No Results Found
      <br>
	  <input type="button" value="Back To Search" onClick="history.back();">
	  </td>
	</tr>
    <tr><td class="layoutLine" valign="middle" align="left" width="302" height="1" colSpan="4"></td></tr>
<%
} 
else
{
%>
    <form name="WorkerSearchResults" action="ViewWorker.jsp" method="get">
        <select name="selectedWorker" size=<%=WorkerResults.length%>>
<%
    /* For each result returned, present in a list on the results page */
    for (int i = 0; i < WorkerResults.length; i ++)
	{
%>
          <option value="<%=WorkerResults[i].getWorkerId()%>"><%=WorkerResults[i].getWorkerName()%></option>
<%
	}
%>
        </select>
	    <br>
	  	<input type="button" value="View Worker" onClick="submit()">
	    <input type="button" value="Back To Search" onClick="history.back();"><br><br>
      </td>
	</tr>
    <tr><td class="layoutLine" valign="middle" align="left" width="302" height="1" colSpan="4"></td></tr>
  </form>
<%
}
%>
</table>
</body>
</html>